/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.struts.Carrera;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Andreina Wilhelm
 */
public class ConsultarCarreraForm extends org.apache.struts.action.ActionForm {
    
    private String carreraCod;
    private Carrera carreraSelected;

    public String getCarreraCod() {
        return carreraCod;
    }

    public void setCarreraCod(String carreraCod) {
        this.carreraCod = carreraCod;
    }

    public Carrera getCarreraSelected() {
        return carreraSelected;
    }

    public void setCarreraSelected(Carrera carreraSelected) {
        this.carreraSelected = carreraSelected;
    }
    

    /**
     *
     */
    public ConsultarCarreraForm() {
        super();
        // TODO Auto-generated constructor stub
    }
    

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        
         // validar el seleccionado no sea Seleccione...
        if (this.carreraCod.equals("Seleccione...")) {
            errors.add("err_selec", new ActionMessage("errors.select"));    // agrego un error porque sino no agarra camino que deberia pero esto no lo voy a mostrar
        } 
        
        return errors;
    }
    
    
    @Override
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        // reset properties
        this.carreraCod = "";
        this.carreraSelected = null;
    }
}
